package com.srwl.mytx.converter;

import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;
import com.srwl.mytx.domain.LatLng;

import java.io.IOException;
import java.lang.reflect.Type;

public class AmapLocationSerializer implements ObjectSerializer {
    @Override
    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
        LatLng latLng = (LatLng) object;
        //为保存在高德云图，适配云图的保留字段而增加 ，格式：经度,纬度（104.394729,31.125698）
        String value = latLng.getLongitude() + "," + latLng.getLatitude();
        serializer.write(value);
    }
}
